﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;


namespace Marmat.Forms
{
    public partial class TabFormPanel
    {
        [Browsable(false)]
        public Rectangle Rectangle
        {
            get
            {
                return new Rectangle(0, 0, this.Width, this.Padding.Top);
            }
        }

        private TabFormCollection _Forms;

        [Browsable(false)]
        public TabFormCollection Forms
        {
            get
            {
                if (this._Forms is null)
                {
                    this._Forms = new TabFormCollection(this);
                }

                return this._Forms;
            }
        }

        /// <summary>
        /// 显示的首个选项卡序号
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        private int FirstIndex { get; set; }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Padding Padding
        {
            get
            {
                return base.Padding;
            }

            set
            {
                base.Padding = value;
            }
        }

        // <TypeConverterAttribute(GetType(Marmat.BindingConverter))>
        public ArcRadius ArcRadius
        {
            get
            {
                return this.m_ArcRadius;
            }

            set
            {
                this.m_ArcRadius = value;
            }
        }

        private ArcRadius m_ArcRadius;
        private Dictionary<System.Windows.Forms.Form, Rectangle> _Rectangles;

        internal Dictionary<System.Windows.Forms.Form, Rectangle> Rectangles
        {
            get
            {
                if (this._Rectangles is null)
                {
                    this._Rectangles = new Dictionary<System.Windows.Forms.Form, Rectangle>();
                }

                return this._Rectangles;
            }
        }

        private System.Windows.Forms.Form _SelectedForm;

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public System.Windows.Forms.Form SelectedForm
        {
            get
            {
                return this._SelectedForm;
            }

            set
            {
                if (!ReferenceEquals(this._SelectedForm, value))
                {
                    try
                    {
                        WindowsAPI.LockWindowUpdate((int)this.Handle);
                        if (this._SelectedForm is object)
                        {
                            this._SelectedForm.Visible = false;
                        }

                        this._SelectedForm = value;
                        if (value is object && value.IsDisposed == false)
                        {
                            value.BringToFront();
                            this._SelectedForm.Visible = true;
                        }

                        this.Invalidate(this.Rectangle);
                        WindowsAPI.LockWindowUpdate((int)IntPtr.Zero);
                    }
                    catch (Exception ex)
                    {
                        WindowsAPI.LockWindowUpdate((int)IntPtr.Zero);
                        throw ex;
                    }
                }
            }
        }

        private bool _ShowIcon = true;

        [DefaultValue(true)]
        public bool ShowIcon
        {
            get
            {
                return this._ShowIcon;
            }

            set
            {
                this._ShowIcon = value;
            }
        }

        private bool m_ShowTabs = true;

        [DefaultValue(true)]
        public bool ShowTabs
        {
            get
            {
                return this.m_ShowTabs;
            }
            set
            {
                this.m_ShowTabs = value;
                this.Padding = new Padding(0, value ? 30 : 0, 0, 0);
                this.PictureBox1.Visible = value;
            }
        }

        private bool _ShowClose = true;

        [DefaultValue(true)]
        public bool ShowClose
        {
            get
            {
                return this._ShowClose;
            }

            set
            {
                this._ShowClose = value;
            }
        }


        private Color _BackColor;

        /// <summary>
        /// 获取或设置控件的背景色。
        /// </summary>
        /// <returns></returns>
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color BackColor
        {
            get
            {
                // If Me._BackColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "BackColor")
                // End If
                return this._BackColor;
            }

            set
            {
                this._BackColor = value;
                this.Panel.BackColor = value;
            }
        }

        private Color _NormalForeColor;

        public Color NormalForeColor
        {
            get
            {
                // If Me._NormalForeColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "NormalForeColor")
                // End If
                return this._NormalForeColor;
            }

            set
            {
                this._NormalForeColor = value;
            }
        }

        private bool _CloseRect;

        internal bool CloseRect
        {
            get
            {
                return this._CloseRect;
            }

            set
            {
                this._CloseRect = value;
            }
        }

        private Color _TopColor;

        public Color TopColor
        {
            get
            {
                // If Me._TopColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "TopColor")
                // End If
                return this._TopColor;
            }

            set
            {
                this._TopColor = value;
            }
        }

        private Color _BottomColor;

        public Color BottomColor
        {
            get
            {
                // If Me._BottomColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "BottomColor")
                // End If
                return this._BottomColor;
            }

            set
            {
                this._BottomColor = value;
            }
        }

        private Color _SelectedTopColor;

        public Color SelectedTopColor
        {
            get
            {
                // If Me._SelectedTopColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "SelectedTopColor")
                // End If
                return this._SelectedTopColor;
            }

            set
            {
                this._SelectedTopColor = value;
            }
        }

        private Color _SelectedBottomColor;

        public Color SelectedBottomColor
        {
            get
            {
                // If Me._SelectedBottomColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "SelectedBottomColor")
                // End If
                return this._SelectedBottomColor;
            }

            set
            {
                this._SelectedBottomColor = value;
            }
        }

        private Font _SelectedFont = new Font("宋体", 9.0f);

        [DefaultValue(typeof(Font), "宋体,9pt")]
        public Font SelectedFont
        {
            get
            {
                return this._SelectedFont;
            }

            set
            {
                this._SelectedFont = value;
            }
        }

        private Color _SelectedFontColor;

        public Color SelectedFontColor
        {
            get
            {
                // If Me._SelectedFontColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "SelectedFontColor")
                // End If
                return this._SelectedFontColor;
            }

            set
            {
                this._SelectedFontColor = value;
            }
        }

        private Color _SelectedForeColor;

        public Color SelectedForeColor
        {
            get
            {
                // If Me._SelectedForeColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "SelectedForeColor")
                // End If
                return this._SelectedForeColor;
            }

            set
            {
                this._SelectedForeColor = value;
            }
        }

        private Color _MouseEnterForeColor;

        public Color MouseEnterForeColor
        {
            get
            {
                // If Me._MouseEnterForeColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "MouseEnterForeColor")
                // End If
                return this._MouseEnterForeColor;
            }

            set
            {
                this._MouseEnterForeColor = value;
            }
        }

        private Color _MouseEnterTopColor;

        public Color MouseEnterTopColor
        {
            get
            {
                // If Me._MouseEnterTopColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "MouseEnterTopColor")
                // End If
                return this._MouseEnterTopColor;
            }

            set
            {
                this._MouseEnterTopColor = value;
            }
        }

        private Color _MouseEnterBottomColor;

        public Color MouseEnterBottomColor
        {
            get
            {
                // If Me._MouseEnterBottomColor = Color.Empty Then
                // Return Control_Skin.GetControlSkin(Me, "MouseEnterBottomColor")
                // End If
                return this._MouseEnterBottomColor;
            }

            set
            {
                this._MouseEnterBottomColor = value;
            }
        }

        private Font _MouseEnterFont = new Font("宋体", 9.0f);

        [DefaultValue(typeof(Font), "宋体,9pt")]
        public Font MouseEnterFont
        {
            get
            {
                return this._MouseEnterFont;
            }

            set
            {
                this._MouseEnterFont = value;
            }
        }

        // Private _MouseEnterFontColor As Color
        // Public Property MouseEnterFontColor As Color
        // Get
        // If Me._MouseEnterFontColor = Color.Empty Then
        // Return Control_Skin.GetControlSkin(Me, "MouseEnterFontColor")
        // End If
        // Return Me._MouseEnterFontColor
        // End Get
        // Set(value As Color)
        // Me._MouseEnterFontColor = value
        // End Set
        // End Property

    }
}